

class Solution {
public:
    TreeNode* sortedArrayToBST(vector<int>& nums) {

        return helper(nums,0,nums.size()-1);
    }
    TreeNode*helper(vector<int>&nums,int left,int right)
    {
        if(left>right) return nullptr;
       int mid=(left+right)/2;
       TreeNode* newnode=new TreeNode(nums[mid]);
       newnode->left=helper(nums,left,mid-1);
       newnode->right=helper(nums,mid+1,right);
       return newnode;
    }
};